-
Notifications
You must be signed in to change notification settings - Fork 0
Improving Examples #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving Examples #492
Conversation
Annotate functions with precise parameter and return types Provide comprehensive docstrings for all public functions Insert inline comments explaining key logging and error‑handling steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the examples and documentation for multiple modules including CSV, JSON, logging, FastAPI, file monitoring, and calendar utilities. The changes add detailed docstrings, type annotations, new helper functions (e.g., for appending and deleting CSV files), and enhanced documentation suitable for modern Python projects.
Reviewed Changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
examples/text_example.py | Added CSV and JSON example functions with detailed docstrings and type hints. |
examples/log_example.py | Updated logging functions with type annotations and improved error handling demonstration. |
examples/json_example.py | Enhanced JSON functions to handle dictionaries and lists with clearer type hints and additional examples. |
examples/file_monitor.py | Improved file monitoring example with full type annotations and refined async logic. |
examples/fastapi_example.py | Updated FastAPI endpoints with richer documentation and additional SQLAlchemy query examples. |
examples/csv_example_with_timer.py | Adjusted import ordering and ensured consistent usage of imports. |
examples/csv_example.py | Introduced functions for appending and deleting CSV files with clear type annotations. |
examples/cal_example.py | Improved calendar examples with type hints and additional edge case demonstrations. |
dsg_lib/common_functions/file_mover.py | Added type annotations and enhanced inline comments for clarity. |
dsg_lib/async_database_functions/database_operations.py | Minor formatting cleanup and removal of extraneous blank lines. |
docs/examples/*.md | Updated documentation across validation, text, log, JSON, file monitor, FastAPI, CSV, and calendar examples with improved readability and consistency. |
Files not reviewed (1)
- coverage.xml: Language not supported
Comments suppressed due to low confidence (2)
examples/text_example.py:26
- [nitpick] Consider using a consistent type hint style (e.g., using the typing module’s List and Dict) across the codebase for clarity and consistency in function signatures.
### `save_csv_example(csv_data: list[list[str]], file_name: str = "example.csv")`
examples/csv_example.py:113
- [nitpick] It would be beneficial to add unit tests for the new CSV functions (such as open_some_data, append_some_data, and delete_example_file) to verify their behavior with various CSV formats and error conditions.
def open_some_data(the_file_name: str) -> List[Dict[str, Any]]:
|
Pull Request Description: Improving Examples
This pull request enhances the existing examples in our documentation to provide clearer and more robust usage scenarios for users of the
dsg_lib
library. The motivation behind these changes is to improve the usability and understanding of our library, ensuring that users can quickly grasp its capabilities and apply them effectively in their own projects.Key Changes:
Enhanced Type Annotations: The examples now utilize Python's type hints, improving code readability and providing better guidance on expected input types.
Expanded Functionality in Examples:
cal_example.md
includes additional functions to handle edge cases, such as invalid inputs, and demonstrates how the library manages unexpected types.csv_example.md
has been updated to include functions for appending and deleting CSV files, showcasing more comprehensive usage of the library's capabilities.Detailed Docstrings: Each function now has a descriptive docstring that outlines its purpose, parameters, and return values. This will help users understand what each function does and how to use it effectively.
Real-World Scenarios: Examples in
fastapi_example.md
have been enriched with clear explanations of what each endpoint does, complete with example requests and expected responses. This will aid users in integrating our library with FastAPI applications.Improved Logging: Logging has been incorporated in the examples to demonstrate best practices for monitoring and debugging, making it easier for users to track their application's behavior.
By implementing these changes, we aim to provide a more intuitive and informative experience for users, encouraging them to leverage the full potential of the
dsg_lib
library. This will not only enhance user satisfaction but also reduce the learning curve for new users, ultimately contributing to a more engaged and productive community.